#include "QCefHideNorWidget.h"


//////////////////////////////////////////////////////////////////////////
//
QCefHideNorWidget::QCefHideNorWidget(bool bHide, QWidget * parent, Qt::WindowFlags flags)
    : QCefNorWidget(parent, flags)
{
    QCEF_DEBUG();

    //
    if (bHide)
    {
        initHide();
    }
}

QCefHideNorWidget::QCefHideNorWidget(const QString & strUrl, bool bHide, QWidget * parent, Qt::WindowFlags flags)
    : QCefNorWidget(strUrl, parent, flags)
{
    QCEF_DEBUG();

    //
    if (bHide)
    {
        initHide();
    }
}

QCefHideNorWidget::~QCefHideNorWidget()
{
    QCEF_DEBUG();
}


int QCefHideNorWidget::initHide()
{
    //
    this->setWindowTitle("QCefHideNorWidget");

    this->setAttribute(Qt::WA_Disabled);
    this->setAttribute(Qt::WA_UpdatesDisabled);
    this->setAttribute(Qt::WA_ForceDisabled);
    this->setAttribute(Qt::WA_ForceUpdatesDisabled);
    this->setAttribute(Qt::WA_NoChildEventsFromChildren);
    this->setAttribute(Qt::WA_NoChildEventsForParent);
    this->setAttribute(Qt::WA_WState_Hidden);
    this->setAttribute(Qt::WA_ShowWithoutActivating);

    this->setDisabled(true);
    this->setVisible(false);

    return 0;
}

void QCefHideNorWidget::firstPolishEvent(QEvent * event)
{
    QCEF_DEBUG();

    DWORD style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED;
    DWORD ex_style = WS_EX_NOACTIVATE;
    this->setGeometry(-10240, -10240, 2048, 2048);

    this->createContainer();
    this->createClient();
    this->createBrowser(this->getFirstUrl(), QSize(1024, 768), style, ex_style);
}


void QCefHideNorWidget::hideWidget()
{
    this->setGeometry(-10240, -10240, 2048, 2048);
    this->hide();
}

void QCefHideNorWidget::showWidget()
{
    this->setGeometry(48, 48, 1024, 768);
    this->show();
}
